// router的文件夹入口文件

import koaRouter from "koa-router"; // 引入路由
import login from "./login"; // 引入自定义login路由
import desktop from "./desktop"; // 引入自定义desktop路由
import list from "./list"; // 引入自定义list路由
import errorPage from "./errorPage"; // 引入自定义errorPage路由
import upload from "./upload"; // 引入自定义上传文件路由upload路由
import user from "./user";
import AuthMiddleware from "../middleware/AuthMiddleware";

const router = new koaRouter(); // 实例化-此处可以设置全局前缀prefix: "/api"


// 调用中间件
router.use('/login', login.routes(), login.allowedMethods()); // 登录

//验证接口是否带有token(login接口不做验证)
//router.use(AuthMiddleware);

router.use('/desktop', desktop.routes(), desktop.allowedMethods()); // 首页desktop
router.use('/list', list.routes(), list.allowedMethods()); // 列表页list
router.use('/errorPage', errorPage.routes(), errorPage.allowedMethods()); // errorPage
router.use('/upload', upload.routes(), upload.allowedMethods()); // upload
router.use('/user', user.routes(), user.allowedMethods()); // 用户api

// 默认重定向到/desktop
router.redirect('/','/desktop');

export default router